package com.huike.web.controller.contract;

import com.github.pagehelper.Page;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.core.page.TableDataInfo;
import com.huike.common.entity.MPTbContract;
import com.huike.contract.service.ContracService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Description TODO
 * @Author hxd
 * @Date 2023-08-30 22:08
 */
@Slf4j
@Api(tags = "合同管理相关接口")
@RestController
@RequestMapping("/contract")
public class ContracController {
    @Resource
    private ContracService contracService;

    /**
     * 获取合同信息2
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    @ApiOperation("获取合同信息2")
    public AjaxResult findId(@PathVariable Long id){
        MPTbContract mpTbContract = contracService.findId(id);
        return AjaxResult.success(mpTbContract);
    }

    /**
     * 查询合同列表
     * @param mpTbContract
     * @return
     */
    @GetMapping("/list")
    @ApiOperation("查询合同列表")
    public TableDataInfo contractList(MPTbContract mpTbContract){
        Page<MPTbContract> mp = contracService.contractList(mpTbContract);
        TableDataInfo tableDataInfo = new TableDataInfo();
        tableDataInfo.setTotal(mp.getTotal());
        tableDataInfo.setRows(mp.getResult());
        tableDataInfo.setCode(200);
        return tableDataInfo;
    }
}
